<template>
	<view>
		<view class="p-4 flex flex-column grid-gap-4">
			<view class="flex bg-white rounded-4 p-4 flex-center grid-gap-2"
				@tap="$page.open('/pages/user/finance/save?channels=alipay_payment_code')">
				<image src="@/static/icons/account/alipay_payment_code.png" style="width:60rpx;height:60rpx;" />
				<view class="flex-1 h9 text-grey">支付宝收款码</view>
				<view class="h8 font-weight-600" v-if="account.alipay_payment_code.name">{{
					account.alipay_payment_code.name
				}}</view>
				<view class="h9 text-placeholder" v-else>未设置</view>
				<uni-icons type="right" color="var(--xl-placeholder)"></uni-icons>
			</view>
			<view class="flex bg-white rounded-4 p-4 flex-center grid-gap-2"
				@tap="$page.open('/pages/user/finance/save?channels=wechat_payment_code')">
				<image src="@/static/icons/account/wechat_payment_code.png" style="width:60rpx;height:60rpx;" />
				<view class="flex-1 h9 text-grey">微信收款码</view>
				<view class="h8 font-weight-600" v-if="account.wechat_payment_code.name">{{
					account.wechat_payment_code.name
				}}</view>
				<view class="h9 text-placeholder" v-else>未设置</view>
				<uni-icons type="right" color="var(--xl-placeholder)"></uni-icons>
			</view>
			<view class="flex bg-white rounded-4 p-4 flex-center grid-gap-2"
				@tap="$page.open('/pages/user/finance/save?channels=wechat_transfer')">
				<image src="@/static/icons/account/wechat_transfer.png" style="width:60rpx;height:60rpx;" />
				<view class="flex-1 h9 text-grey">转账到微信零钱</view>
				<view class="h8 font-weight-600" v-if="account.wechat_transfer.name">{{ account.wechat_transfer.name }}
				</view>
				<view class="h9 text-placeholder" v-else>未设置</view>
				<uni-icons type="right" color="var(--xl-placeholder)"></uni-icons>
			</view>
			<view class="flex bg-white rounded-4 p-4 flex-center grid-gap-2"
				@tap="$page.open('/pages/user/finance/save?channels=bank_transfer')">
				<image src="@/static/icons/account/bank_transfer.png" style="width:60rpx;height:60rpx;" />
				<view class="flex-1 h9 text-grey">银行卡转账</view>
				<view class="h8 font-weight-600" v-if="account.bank_transfer.name">{{ account.bank_transfer.bank }} {{
					account.bank_transfer.name }}</view>
				<view class="h9 text-placeholder" v-else>未设置</view>
				<uni-icons type="right" color="var(--xl-placeholder)"></uni-icons>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import { $page, $api, $message } from "@/utils";
const account = ref({
	alipay_payment_code: {
		channels: 'alipay_payment_code',
		name: '',
		mobile: '',
		qrcode: ''
	},
	wechat_payment_code: {
		channels: 'wechat_payment_code',
		name: '',
		mobile: '',
		qrcode: ''
	},
	wechat_transfer: {
		channels: 'wechat_transfer',
		name: '',
		mobile: ''
	},
	bank_transfer: {
		channels: 'bank_transfer',
		name: '',
		mobile: '',
		account: '',
		bank: ''
	},
});
const getAccount = () => {
	$api.UserFinanceAccount.index().then((data: any) => {
		for (const key in data) {
			if (Object.hasOwnProperty.call(data, key)) {
				const item = data[key];
				account.value[key] = item;
			}
		}
	}).catch((err: any) => {
		$message.error(err.msg);
	})
}
onShow(() => {
	getAccount();
})
</script>
